package com.pingao.mp.handle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 2.开启定时任务
public class StaticScheduleTask {
    private final static Logger logger = LoggerFactory.getLogger(StaticScheduleTask.class);

    @Scheduled(cron = "0 0/1 14-16,21-23 * * ?")  // 零到九点、21点到23点，每10分钟
    private void configureTasks() {
        logger.info("configureTasks:" + LocalDateTime.now().toString());
    }
}
